package com.unionftech.common.utils

import android.text.TextPaint
import android.text.style.ClickableSpan
import android.view.View
import androidx.core.content.res.ComplexColorCompat
import com.unionftech.common.webview.CommonWebViewActivity

class CustomClickableSpan(
    private val title: String,
    private val url: String,
    private val isUnderlineText: Boolean,
    private val isPdf: Boolean
) : ClickableSpan() {
    override fun onClick(widget: View) {
        val context = widget.context
        if (isPdf) {
            CommonWebViewActivity.startPdfFile(context, title, url)
        } else {
            CommonWebViewActivity.startThis(context, title, url)
        }
    }

    override fun updateDrawState(ds: TextPaint) {
        ds.isUnderlineText = isUnderlineText
    }
}